package com.lmaye.design.patterns.creation.prototype;

/**
 * -- Rabbit
 *
 * @author lmay.Zhou
 * @date 2020/11/18 23:46 星期三
 * @qq 379839355
 * @email lmay@lmaye.com
 * @since JDK1.8
 */
public class Rabbit implements Cloneable {
    /**
     * name
     */
    private String name;

    /**
     * friend
     */
    private Rabbit friend;

    public Rabbit() {

    }

    public Rabbit(String name, Rabbit friend) {
        this.name = name;
        this.friend = friend;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        System.out.println("原型复制成功");
        return super.clone();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Rabbit getFriend() {
        return friend;
    }

    public void setFriend(Rabbit friend) {
        this.friend = friend;
    }

    @Override
    public String toString() {
        return "Rabbit{" +
                "name='" + name + '\'' +
                ", friend=" + friend +
                '}';
    }
}
